package com.cooper.dao.core;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.Insert;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;

import com.cooper.entity.Keygen;

@DAO
public interface KeygenDAO {
	
	@ReturnGeneratedKeys
	@Insert(tableName="srd_keygen")
	Long addEntity(Keygen keygen);
	
	@SQL("select * from srd_keygen t where deleted='n' and key_name=:1 ")
	Keygen loadByName(String keyName) ;
	
	@SQL("update srd_keygen set next_value = :2 where deleted='n' and key_name=:1 ")
	boolean updateEntity(String keyName, long nextValue);
	
	@SQL("update srd_keygen set deleted='y' where deleted='n' and key_name=:1 ")
	void deleteEntity(String keyName) throws Exception;
}
